package com.waiting.leetcode;

/**
 * @Description
 * @Author bjweitingting
 * @Date 2019/3/14
 **/
public class BestTimeToBuyAndSellStock121 {
    public static void main(String[] args) {

    }

    /**
     * 121 只交易一次
     * @param prices
     * @return
     */
    public int maxProfit121(int[] prices) {
        if (prices == null || prices.length < 1) {
            return 0;
        }
        int min = prices[0];
        int max = 0;
        for (int i = 1; i < prices.length; i++) {
            int tmp = prices[i] - min;
            max = Math.max(max, tmp);
            min = Math.min(min, prices[i]);
        }
        return max;
    }

    /**
     * 122 多买多卖 问题
     * @param prices
     * @return
     */
//    public int maxProfit(int[] prices) {
//
//    }
}
